﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GameEditor.Common.InternalDialogs
{
    internal partial class ObjectSelectDialog : Form
    {
        public ObjectSelectDialog()
        {
            InitializeComponent();
        }

        internal DialogResult ShowDialog(IWin32Window owner, string text, string caption, NamedObject[] objects, ref NamedObject selected)
        {
            label1.Text = text;
            Text = caption;
            comboBox1.Items.AddRange(objects);
            if (selected != null)
            {
                comboBox1.SelectedItem = selected;
            }
            else
                comboBox1.SelectedIndex = 0;
            DialogResult dr = ShowDialog(owner);

            if (dr == DialogResult.OK)
            {
                selected = comboBox1.SelectedItem as NamedObject;
            }
            return dr;
        }

        private void OnOK(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }
    }
}
